package com.sphd.education.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sphd.education.R;
import com.sphd.education.info.ClassifyOne;
import com.sphd.education.info.ClassifyTwo;

import java.util.List;


/**
 * Created by Administrator on 2015/10/16.
 */
public class ClassifyTwoAdapter extends BaseAdapter {
    private Context context;
    private List<ClassifyTwo> classifyTwoList;
    private int layoutInt;

    public ClassifyTwoAdapter(Context context, List<ClassifyTwo> classifyTwoList, int layoutInt) {
        this.context = context;
        this.classifyTwoList = classifyTwoList;
        this.layoutInt = layoutInt;
    }

    @Override
    public int getCount() {
        return classifyTwoList.size();
    }

    @Override
    public Object getItem(int position) {
        return classifyTwoList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewClassify viewClassify=null;

        if(viewClassify==null){
            viewClassify= new ViewClassify();
            convertView= View.inflate(context,layoutInt,null);

            viewClassify.fenlei = (TextView) convertView.findViewById(R.id.classify_one_textview);

            convertView.setTag(viewClassify);
        }else{
            viewClassify= (ViewClassify) convertView.getTag();
        }
//        viewClassify.fenlei.setBackgroundResource(R.color.mediumslateblue);
        viewClassify.fenlei.setTextColor(context.getResources().getColor(R.color.mediumslateblue));
        viewClassify.fenlei.setText(classifyTwoList.get(position).getClassify());

        return convertView;
    }

    class ViewClassify{
        TextView fenlei;

    }

}
